package com.sgb.kjwl.view.widget.transport

import android.content.Context
import android.os.Bundle
import com.sgb.kjwl.R
import com.sgb.kjwl.databinding.SheetDialogCompanyInfoBinding
import com.swgk.core.dialog.BaseBottomDialog
import com.swgk.core.dialog.DialogViewHolder

/**
 * Describe:    开票信息对话框（底部）
 * Author:  yangLei
 * Date:    2022/1/12
 */
class InvoiceBottomDialog(context: Context, dialogCallBack: DialogCallBack?) :
    BaseBottomDialog(context, dialogCallBack) {

    private var mBinding: SheetDialogCompanyInfoBinding? = null
    private var invoiceInfo: InvoiceInfo? = null
    fun setInvoiceInfo(invoiceInfo: InvoiceInfo?) {
        this.invoiceInfo = invoiceInfo
        setData(invoiceInfo)
    }

    override fun dialogLayout(): Int {
        return R.layout.sheet_dialog_company_info
    }

    override fun initView(holder: DialogViewHolder, savedInstanceState: Bundle) {
        mBinding = holder.getmBinding() as SheetDialogCompanyInfoBinding
        mBinding!!.close.setOnClickListener { dismiss() }
        setCanceledOnTouchOutside(false)
        setData(invoiceInfo)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    private fun setData(info: InvoiceInfo?) {
        info?.apply {
            companyName?.apply {
                mBinding?.companyName!!.text = this
            }
            taxID?.apply {
                mBinding?.dutyNum!!.text = this
            }
            address?.apply {
                mBinding?.address!!.text = this
            }
            phone_number?.apply {
                mBinding?.phone!!.text = this
            }
            bank_name?.apply {
                mBinding?.bank!!.text = this
            }
            bank_account?.apply {
                mBinding?.bankAccount!!.text = this
            }
            ban_no?.apply {
                mBinding?.bankNub!!.text = this
            }
        }
    }

    /**
     * 发票信息类
     */
    class InvoiceInfo(
        val companyName: String,
        val taxID: String,
        val address: String,
        val phone_number: String,
        val bank_name: String,
        val bank_account: String,
        val ban_no: String
    )


}